//
//  HFAutoLoginController.swift
//  HFWeChat
//
//  Created by 黄来峰 on 16/4/18.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class HFAutoLoginController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        NSNotificationCenter.defaultCenter().addObserver(self, selector: "dismissAutoLoginController", name: "DISMISSAUTOLOGINCONTROLLER", object: nil)
        
        
        let autoview = HFAutoview()
        view = autoview
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "自动填充", style: UIBarButtonItemStyle.Plain, target: self, action: "autoLogin")
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "取消", style: UIBarButtonItemStyle.Plain, target: self, action: "cancleLogin")
        navigationItem.title = "微博登录"
        
    }
    
    //MARK - 自动登录方法
   @objc private func autoLogin(){
    //document.getElementById('userId').value='';document.getElementById('passwd').value=''
   let jsstring = "document.getElementById('userId').value='15565676363';document.getElementById('passwd').value='123321huang'"
     let v =   view as! HFAutoview

    v.stringByEvaluatingJavaScriptFromString(jsstring)
    
    }
    
   @objc private func cancleLogin(){
    
    
    
    }
    
    
     //MARK: -干掉登录界面
   @objc private func dismissAutoLoginController(){
    dismissViewControllerAnimated(false, completion: nil)
    
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
